Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch errors on IP resolve #45

Merged

Conversation

Snuffy2
Copy link
Collaborator

@Snuffy2 Snuffy2 commented Dec 11, 2023

Wanted to catch DNS resolve errors. I caused it due to my router settings, but JPP will crash if it can't resolve the EnelX server IP with the external 1.1.1.1 IP.

juicepassproxy  | Traceback (most recent call last):
juicepassproxy  |   File "/juicepassproxy/juicepassproxy.py", line 661, in <module>
juicepassproxy  |     main()
juicepassproxy  |   File "/juicepassproxy/juicepassproxy.py", line 603, in main
juicepassproxy  |     elif enelx_server_ip := resolve_ip_external_dns(enelx_server):
juicepassproxy  |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
juicepassproxy  |   File "/juicepassproxy/juicepassproxy.py", line 395, in resolve_ip_external_dns
juicepassproxy  |     answers = res.resolve(address)
juicepassproxy  |               ^^^^^^^^^^^^^^^^^^^^
juicepassproxy  |   File "/usr/local/lib/python3.12/site-packages/dns/resolver.py", line 1321, in resolve
juicepassproxy  |     timeout = self._compute_timeout(start, lifetime, resolution.errors)
juicepassproxy  |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
juicepassproxy  |   File "/usr/local/lib/python3.12/site-packages/dns/resolver.py", line 1075, in _compute_timeout
juicepassproxy  |     raise LifetimeTimeout(timeout=duration, errors=errors)
juicepassproxy  | dns.resolver.LifetimeTimeout: The resolution lifetime expired after 5.401 seconds: Server Do53:1.1.1.1@53 answered The DNS operation timed out.; Server Do53:1.1.1.1@53 answered The DNS operation timed out.; Server Do53:1.1.1.1@53 answered The DNS operation timed out.

Now it handles it as just a Warning and JPP will fallback to the Enel X IP in the Config or the Default one:

juicepassproxy  | 2023-12-11 07:57:14,477 WARNING    Unable to resolve juicenet-udp-prod3-usa.enelx.com: The resolution lifetime expired after 5.402 seconds: Server Do53:1.1.1.1@53 answered The DNS operation timed out.; Server Do53:1.1.1.1@53 answered The DNS operation timed out.; Server Do53:1.1.1.1@53 answered The DNS operation timed out.

@snicker
Copy link
Collaborator

snicker commented Apr 2, 2024

@Snuffy2 let me know if you want to merge this one- thinking we have a couple things to target a release this week or next

@Snuffy2 Snuffy2 merged commit 0c070fc into JuiceRescue:master Apr 9, 2024
@Snuffy2 Snuffy2 deleted the Catch-LifetimeTimeout-on-DNS-Resolve branch April 22, 2024 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants